<template>
  <audio id="player" ref="audio" loop>
    <source src="/a.mp3" type="audio/mp3" />
  </audio>
</template>

<script>
export default {
  data() {
    return {}
  },
  methods: {
    stop() {
      if (this.$refs.audio) {
        this.$refs.audio.pause()
        this.$refs.audio.currentTime = 0
      }
    },
    play() {
      this.$refs.audio.play()
    },
  },
  beforeDestroy() {
    this.stop()
  },
}
</script>

<style>
</style>